package controls.challengeHistory {

	import mx.collections.Grouping;
	import mx.collections.GroupingField;
	import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;

	/**
	 * @author Brent Kersanske
	 */ 
	public class ChallengeHistoryUtilities {

		/**
		 * Generates a grouping of fields for consumption by a grouping collection object.
		 */ 
		public static function generateGrouping(groupingFieldName:String):Grouping {
			var grouping:Grouping 		    = new Grouping();
			grouping.fields 	  			= new Array();
			var groupingField:GroupingField = new GroupingField(groupingFieldName);
			grouping.fields.push(groupingField);
			return grouping;
		}
		
		/**
		 * Generates an advanced data grid column.
		 */ 
		public static function generateColumn(headerText:String, dataField:String, width:Number=120, styleFunction:Function=null):AdvancedDataGridColumn {
			var column:AdvancedDataGridColumn = new AdvancedDataGridColumn(headerText);
			column.dataField 				  = dataField;
			column.width	 				  = width;
			column.styleFunction 			  = styleFunction;
			return column;
		}	
	}
}